//
//  AppDelegate.swift
//  微博Swift
//
//  Created by  justinchou on 16/2/23.
//  Copyright © 2016年  justinchou. All rights reserved.
//

import UIKit
import AFNetworking

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // MARK:- 设置启动控制器
        window = UIWindow()
        window?.frame = UIScreen.mainScreen().bounds
        window?.rootViewController = MainViewController()
        window?.makeKeyAndVisible()

        setupGlobalAttribute()
        
        setupAFNetworking()
        
        return true
    }

}

// MARK:- 全局设置外观
extension AppDelegate {
    
    private func setupGlobalAttribute() {
        UINavigationBar.appearance().tintColor = UIColor.orangeColor()
    }
}
// MARK:- 设置AFNetworking
extension AppDelegate {
    
    private func setupAFNetworking() {
        //设置状态栏指示器
        AFNetworkActivityIndicatorManager.sharedManager().enabled = true
        
        //设置缓存，nil为系统默认缓存路径
        NSURLCache.setSharedURLCache(NSURLCache(
            memoryCapacity: 4 * 1024 * 1024,
            diskCapacity: 20 * 1024 * 1024,
            diskPath: nil))
    }
}

